package com.gtxc.kotlinmvvm.utlis;

import android.animation.ValueAnimator;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * FileName:AnimationUtis
 * Author：Administrator
 * Date:2021 2021/9/30 13:28
 * Copyright (C), 2020-2021,成都拇音科技有限公司
 * <p>
 * <p>
 * Description: zwl
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
public class AnimationUtis {
    //图片上下浮动
    public static void setTranslateAnimation(TextView iv_chat_head) {
        ValueAnimator animator = ValueAnimator.ofInt(0, 25, 0);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int currentValue = (Integer) animation.getAnimatedValue();
                // 获得改变后的值


                // 输出改变后的值

                // 步骤4：将改变后的值赋给对象的属性值，下面会详细说明
//                iv_chat_head.setproperty(currentValue);

                iv_chat_head.setTranslationY(currentValue);

                // 步骤5：刷新视图，即重新绘制，从而实现动画效果
                iv_chat_head.requestLayout();
            }
        });
        animator.setRepeatMode(ValueAnimator.RESTART);
        animator.setRepeatCount(ValueAnimator.INFINITE);
        animator.setInterpolator(new AccelerateDecelerateInterpolator());
        animator.setDuration(800);
        animator.start();
    }
}
